﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DomainDriver.DomainModeling.Constraints;
using DomainDriver.DomainModeling.DomainModels;
using DomainDriver.DomainModeling.DomainObjects;
using DomainDriver.DomainModeling.Repositories;
using AutomotivePricingModel.BodyStyles;
using AutomotivePricingModel.DriveTrainTypes;
using AutomotivePricingModel.TransmissionTypes;

namespace AutomotivePricingModel
{
    public class AutomotivePricingFactory
    {
        public static KEYED_DOMAIN_OBJECT CreateBlankDomainObject<KEY, KEYED_DOMAIN_OBJECT>()
            where KEYED_DOMAIN_OBJECT : IKeyedDomainObject<KEY, KEYED_DOMAIN_OBJECT>, new()
        {
            return new KEYED_DOMAIN_OBJECT();
        }

        public static void LoadBodyStyleValues(IDomainModel domainModel)
        {
            Type enumType = typeof(BodyStyleEnum);
            IRepository<BodyStyleEnum, BodyStyle> repository = domainModel.GetRepository<BodyStyleEnum, BodyStyle>();

            foreach (BodyStyleEnum key in Enum.GetValues(enumType))
            {
                if (repository.Exists(key))
                { continue; }

                BodyStyle domainObject = new BodyStyle(key);
                repository.Add(domainObject);
            }
        }

        public static void LoadDriveTrainTypeValues(IDomainModel domainModel)
        {
            Type enumType = typeof(DriveTrainTypeEnum);
            IRepository<DriveTrainTypeEnum, DriveTrainType> repository = domainModel.GetRepository<DriveTrainTypeEnum, DriveTrainType>();

            foreach (DriveTrainTypeEnum key in Enum.GetValues(enumType))
            {
                if (repository.Exists(key))
                { continue; }

                DriveTrainType domainObject = new DriveTrainType(key);
                repository.Add(domainObject);
            }
        }

        public static void LoadTransmissionTypeValues(IDomainModel domainModel)
        {
            Type enumType = typeof(TransmissionTypeEnum);
            IRepository<TransmissionTypeEnum, TransmissionType> repository = domainModel.GetRepository<TransmissionTypeEnum, TransmissionType>();

            foreach (TransmissionTypeEnum key in Enum.GetValues(enumType))
            {
                if (repository.Exists(key))
                { continue; }

                TransmissionType domainObject = new TransmissionType(key);
                repository.Add(domainObject);
            }
        }
    }
}